home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJEMU106.ARJ / E03.CC < prev    next >
C/C++ Source or Header  |  1991-04-25  |  1KB  |  78 lines

  1. #include "emu.h"
  2. #include "rmov.h"
  3. #include "compare.h"
  4.  
  5. void emu_03()
  6. {
  7.   if (empty())
  8.     return;
  9.   if (modrm > 0277)
  10.   {
  11.     // fcomp st(i)
  12.     if (empty(modrm&7))
  13.     {
  14.       setcc(SW_C3|SW_C2|SW_C0);
  15.       return;
  16.     }
  17.     int c = compare(st(), st(modrm&7));
  18.     st().tag = TW_E;
  19.     top++;
  20.     int f;
  21.     if (c & COMP_NAN)
  22.     {
  23.       exception(EX_I);
  24.       f = SW_C3 | SW_C2 | SW_C0;
  25.     }
  26.     else
  27.       switch (c)
  28.       {
  29.         case COMP_A_LT_B:
  30.           f = SW_C0;
  31.           break;
  32.         case COMP_A_EQ_B:
  33.           f = SW_C3;
  34.           break;
  35.         case COMP_A_GT_B:
  36.           f = 0;
  37.           break;
  38.         case COMP_NOCOMP:
  39.           f = SW_C3 | SW_C2 | SW_C0;
  40.           break;
  41.       }
  42.     setcc(f);
  43.     
  44.   }
  45.   else
  46.   {
  47.     // fcom m32real
  48.     reg t;
  49.     r_mov((float *)get_modrm(), t);
  50.     int c = compare(st(), t);
  51.     st().tag = TW_E;
  52.     top++;
  53.     int f;
  54.     if (c & COMP_NAN)
  55.     {
  56.       exception(EX_I);
  57.       f = SW_C3 | SW_C2 | SW_C0;
  58.     }
  59.     else
  60.       switch (c)
  61.       {
  62.         case COMP_A_LT_B:
  63.           f = SW_C0;
  64.           break;
  65.         case COMP_A_EQ_B:
  66.           f = SW_C3;
  67.           break;
  68.         case COMP_A_GT_B:
  69.           f = 0;
  70.           break;
  71.         case COMP_NOCOMP:
  72.           f = SW_C3 | SW_C2 | SW_C0;
  73.           break;
  74.       }
  75.     setcc(f);
  76.   }
  77. }
  78.